//
//  PopverPresentationController.swift
//  PersonnalDiary
//
//  Created by 徐宽阔 on 15/9/28.
//  Copyright © 2015年 XDKOO. All rights reserved.
//

import UIKit

class PopverPresentationController: UIPresentationController {
    
    var PopverFrame:CGRect = CGRectZero
    
    override func containerViewWillLayoutSubviews() {
        
        presentedView()?.frame = PopverFrame
        
        containerView?.insertSubview(cover, atIndex: 0)
    }
    
    
    private lazy var cover:UIView = {
        let cover = UIView()
        cover.frame = UIScreen.mainScreen().bounds
        cover.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        
        let tap = UITapGestureRecognizer(target: self, action: Selector("coverTap"))
        cover.addGestureRecognizer(tap)
        return cover
    }()
    
    func coverTap()
    {
        presentedViewController.dismissViewControllerAnimated(true, completion: nil)
    }
}
